<?php 
	/**
	 * 提现记录
	 */
    session_start();
    require_once("../includes/public.inc.php");
    $openid = isset($_SESSION['openid'])?$_SESSION['openid']:'';
    $openusers =  mysql_fetch_array(mysql_query("select * from ".DBQIAN."users where openid='".$openid."' order by id desc limit 1"));
	//print_r($openusers);exit;
    if ($openusers) 
    {
        $cash = mysql_query("select * from ".DBQIAN."tixian where openid='".$openid."' order by time");  
		$cash_log = array();
		$totalmoney = 0.00;
        while ($row = mysql_fetch_array($cash))
		{
			$cash_log[] = $row;
			$totalmoney += $row['amount'];
		}
		$px = mysql_query('SELECT sum(amount) as total_money,id,openid FROM `yifenduohao_tixian` group by openid order by total_money desc');
		$px_array =  array();
		$px_amount = array();
    	while ($rowpx = mysql_fetch_array($px))
		{
			$px_array[] = $rowpx;
		}
		foreach ($px_array as $k=>$p)
		{
			if ($openid == $p['openid'])
			{
				$px_amount['total_money'] = $p['total_money']; 
				$px_amount['sort'] = $k+1;
			}
		}
		/*$sort = array(  
		        'direction' => 'SORT_DESC', //排序顺序标志 SORT_DESC 降序；SORT_ASC 升序  
		        'field'     => 'total_money',       //排序字段  
		);  
		$arrSort = array();  
		foreach($px_array AS $uniqid => $u){  
		    foreach($u AS $key=>$value){  
		        $arrSort[$key][$uniqid] = $value;  
		    }  
		}  
		if($sort['direction']){  
		    array_multisort($arrSort[$sort['field']], constant($sort['direction']), $px_array);  
		}*/
    }
    else
    {
       echo "<script>alert('非法进入!');history.back();</script>";
       exit;
    }
?>
<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,user-scalable=no,maximum-scale=1,initial-scale=1">
<title>提现记录</title>
<link type="text/css" href="css/css.css" rel="stylesheet" />
<link rel="stylesheet" href="css/style.css" />
</head>
<body>
<ul class="top-tool" style="top:0px; left:0px">
    <span class="back"><a href="javascript:history.go(-1)"><img src="./image/back_icon.png"></a></span>
    <span class="title">提现记录</span>
</ul>
<div style="height:50px"></div>
<div id="xq" class="pz-panel">
	<ul class="navs">
	<li><img src="<?=$openusers['headimg_url']?>" alt="头像"><p><?=$openusers['name']?></p></li>
    <li class="center"><img src="./image/tx_icon.png"><p>可提现：<?=$openusers['credit']?>元</p></li>
    <li><img src="./image/txpm.png"><p>提现排名：<?=$px_amount['sort']?></p></li>
	</ul>
</div>
<div id="xq" class="pz-panel" style="margin-top:28px;">
<section id="" class="cd-container">
<!--此处代码有数据时遍历用-->
      <form method="post" action="withdrawal.php" >
		<input type="text" value="" name="amount" placeholder="提现金额" style="width:100%;height:38px;text-align:center;border-radius:6px;border:1px solid #ccc;" /> <br>
		<input type="hidden" value="<?=$openid?>" name="openid" />
		<p style="text-align:center;width:100%;">注意:一次提现金额最低为2元，最高200元</p> 	
		<?if($openusers['credit']<2):?>
		<input type="button" value="提现" style="width:100%;height:38px;text-align:center;font-size:18px;font-weight:bold;border-radius:6px;border:0px solid #ccc;" /> <br>
      	<?else:?>
      	<input type="submit" value="提现" style="width:100%;height:38px;text-align:center;font-size:18px;font-weight:bold;color:#fff;background:#2299dd;border-radius:6px;border:0px solid #ccc;" /> <br>	
      	<?endif;?>
      </form>
</section>
</div>
<div class="footer-tool">
	<div style="padding:0px;position:relative;margin:8px 6px;">
        <ul class="nav">
	        <li onClick="location.href='hblog.php'"><img src="./image/hb_icon.png"><p>红包</p></li>
		    <li onClick="location.href='cashlog.php'"><img src="./image/tx_icon.png"><p>提现</p></li>
		    <li onClick="location.href='productshow.php'"><img src="./image/cp_icon.png"><p>产品</p></li>
		    <li style="border-right:none" onClick="location.href='person.php'">
		       <img src="./image/gr_icon.png">
		       <p>我的</p>
		    </li>
        </ul>
	    <div style="clear:left">
	    </div>
	</div>
</div>
</body>
</html>